import java.util.*;

public class Main {
    public static void main(String[] args) {
        String str="A man, a plan, a canal: Panama";
        System.out.println(isPalindrome(str));
        int n=5;
        System.out.println(generate(n));
    }
    public static boolean isPalindrome(String s) {
        String str=s.toLowerCase();
        int left=0;
        int right=str.length()-1;
        while(left<right){
            while(left<right&&!(str.charAt(left)>='a'&&str.charAt(left)<='z'||str.charAt(left)>='0'&&str.charAt(left)<='9')){
                left++;
            }
            while(left<right&&!(str.charAt(right)>='a'&&str.charAt(right)<='z'||str.charAt(right)>='0'&&str.charAt(right)<='9')){
                right--;
            }
            if(str.charAt(left)!=str.charAt(right)){
                return false;
            }
            left++;
            right--;
        }
        return true;
    }
    public static List<List<Integer>> generate(int numRows) {
        List<List<Integer>> array=new ArrayList<>();
        for(int i=0;i<numRows;i++){
            List<Integer> arr=new ArrayList<>();
            for(int j=0;j<=i;j++){
                if(j==0||j==i){
                    arr.add(1);
                }else{
                    arr.add(array.get(i-1).get(j-1)+array.get(i-1).get(j));
                }
            }
            array.add(arr);
        }
        return array;
    }
}